package com.zang.blogz.enmus;

import io.github.vampireachao.stream.core.optional.Opp;
import io.github.vampireachao.stream.core.optional.Sf;
import io.github.vampireachao.stream.core.stream.Steam;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 请我吃早饭
 * @since 2022/10/13
 */
@AllArgsConstructor
@Getter
public enum MarkdownTypeEnum {

    /**
     *
     */
    NORMAL("", "normalArticleImportStrategyImpl");

    /**
     * 类型
     */
    private final String type;

    /**
     * 策略
     */
    private final String strategy;

    /**
     * @param name 文件类型
     * @return {@link String} 所使用策略bean
     */
    public static String getMarkDownType(String name){

        return Sf.ofStr(name).mayLet(s -> Steam.of(MarkdownTypeEnum.values())
                .findFirst(v -> v.getType().equalsIgnoreCase(name))
                .orElse(NORMAL).getStrategy()).get();
    }
}
